/*
 *  Copyright 2003 by Spectrum Digital Incorporated.
 *  All rights reserved. Property of Spectrum Digital Incorporated.
 */
 
/*
 *  ======== evmdm642_pci.c ========
 *  PCI module for the EVMDM642
 */
 
#include <csl.h>
#include <csl_pci.h>

#include "evmdm642.h"
#include "evmdm642_pci.h"

Int16 EVMDM642_PCI_config(Uint16 *config)
{
    Uint16 i, checksum;
    
    /* If EEPROM not properly connected, return fail code */
    if (PCI_eepromTest() == 0)
        return 1;

    /* Write all registers based on config structure */
    for (i = 0; i < EVMDM642_PCI_CONFIGREGS; i++)
        PCI_eepromWrite(i, config[i]);
        
    /* Compute checksum */
    checksum = 0xAAAA;
    for (i = 0; i < EVMDM642_PCI_CONFIGREGS; i++)
        checksum ^= config[i];
    
    /* Write checksum */
    PCI_eepromWrite(EVMDM642_PCI_CONFIGREGS, checksum);
        
    return 0;
}

